using System;
using System.Data;
using System.Data.SqlClient;


/// <summary>
/// Summary description for ResumeClass
/// </summary>
public partial class SQLServerClass
{
   public string AddNewUpdateResume(
   string resumeID,
   string userID,
   string resumeTitle,
   string contactEmail,
   string objective,
   string experienceYear, 
   string currentCompany,
   string viewable, 
   string template,
   bool confidential)
    {
        errorMessage = "";
        string returnValue = "";
        try
        {
            OpenConnection();
            sqlCommand = new SqlCommand();
            sqlCommand.CommandText = "SPJSResume";
            sqlCommand.Connection = sqlConnection;
            sqlCommand.CommandType =
            CommandType.StoredProcedure;
            sqlCommand.Parameters.AddWithValue(
            "@ResumeID", resumeID);
            sqlCommand.Parameters.AddWithValue(
            "@UserID", userID);
            sqlCommand.Parameters.AddWithValue(
            "@ResumeTitle", resumeTitle);
            sqlCommand.Parameters.AddWithValue(
            "@ContactEmail", contactEmail);
            sqlCommand.Parameters.AddWithValue(
            "@Objective", objective);
            sqlCommand.Parameters.AddWithValue(
            "@ExperienceYear", experienceYear);
            sqlCommand.Parameters.AddWithValue(
            "@CurrentCompany", currentCompany);
            sqlCommand.Parameters.AddWithValue(
            "@Viewable", viewable);
            sqlCommand.Parameters.AddWithValue(
            "@TemplateResume", template);
            sqlCommand.Parameters.AddWithValue(
            "@Confidental", confidential);
            SqlParameter sqlParameter =
            new SqlParameter("@ReturnValue", "");
            sqlParameter.Direction = ParameterDirection.ReturnValue;
            sqlCommand.ExecuteNonQuery();
            returnValue = Convert.ToString(sqlParameter.Value);
            CloseConnection();
        }
        catch (SqlException sql)
        {
            errorCode = sql.Number;
            errorMessage = sql.Message;
        }
        catch (Exception ex)
        {
            errorMessage = ex.Message;

        }
        return returnValue;
    }
    
   public bool AddNewUpdateResume(
   bool flag,
   string resumeID,
   string jobPosition,
   string jobCategoryID,
   string jobIndustryID,
   string provinceID,
   string city,
   string salaryFrom,
   string salarytTo,
   string currency,
   bool salaryNegotive,
   bool relocate, 
   string workType,
   string experienceLevel,
   string available)
    {
        errorMessage = "";
        bool save = false;
        try
        {
            OpenConnection();
            sqlCommand = new SqlCommand();
            sqlCommand.CommandText = "SPJSResumeDetail";
            sqlCommand.Connection = sqlConnection;
            sqlCommand.CommandType =
            CommandType.StoredProcedure;
            sqlCommand.Parameters.AddWithValue(
            "@Flag", flag);
            sqlCommand.Parameters.AddWithValue(
            "@ResumeID", resumeID);
            sqlCommand.Parameters.AddWithValue(
            "@JobPosition", jobPosition);
            sqlCommand.Parameters.AddWithValue(
            "@JobCategoryID", jobCategoryID);
            sqlCommand.Parameters.AddWithValue(
            "@JobIndustryID", jobIndustryID);
            sqlCommand.Parameters.AddWithValue(
            "@ProvinceID", provinceID);
            sqlCommand.Parameters.AddWithValue(
            "@City", city);
            sqlCommand.Parameters.AddWithValue(
            "@SalaryFrom", salaryFrom);
            sqlCommand.Parameters.AddWithValue(
            "@SalaryTo", salarytTo);
            sqlCommand.Parameters.AddWithValue(
            "@Currency", currency);
            sqlCommand.Parameters.AddWithValue(
            "@SalaryNegotive", salaryNegotive);
            sqlCommand.Parameters.AddWithValue(
            "@Relocate", relocate);

            sqlCommand.Parameters.AddWithValue(
                       "@WorkType", workType);
            sqlCommand.Parameters.AddWithValue(
                "@ExperienceLevel", experienceLevel);
            sqlCommand.Parameters.AddWithValue(
               "@Available", available);

            sqlCommand.ExecuteNonQuery();
            save = true;
            CloseConnection();
        }
        catch (SqlException sql)
        {
            errorCode = sql.Number;
            errorMessage = sql.Message;
        }
        catch (Exception ex)
        {
            errorMessage = ex.Message;

        }
        return save;
    }
   public bool AddNewUpdateResume(
   bool flag,
   string resumeID,
   string strength,
   string weekness,
   string hobbies,
   string family,
   string reference)
    {
        errorMessage = "";
        bool save = false;
        try
        {
            OpenConnection();
            sqlCommand = new SqlCommand();
            sqlCommand.CommandText = "SPJSOthers";
            sqlCommand.Connection = sqlConnection;
            sqlCommand.CommandType =
            CommandType.StoredProcedure;
            sqlCommand.Parameters.AddWithValue(
            "@Flag", flag);
            sqlCommand.Parameters.AddWithValue(
            "@ResumeID", resumeID);
            sqlCommand.Parameters.AddWithValue(
            "@Strength", strength);
            sqlCommand.Parameters.AddWithValue(
            "@Weekness", weekness);
            sqlCommand.Parameters.AddWithValue(
            "@Hobbies", hobbies);
            sqlCommand.Parameters.AddWithValue(
            "@Family", family);
            sqlCommand.Parameters.AddWithValue(
            "@Reference", reference);            
            sqlCommand.ExecuteNonQuery();
            save = true;
            CloseConnection();
        }
        catch (SqlException sql)
        {
            errorCode = sql.Number;
            errorMessage = sql.Message;
        }
        catch (Exception ex)
        {
            errorMessage = ex.Message;

        }
        return save;
    }
}
